#pragma once

#include "NVIDIAGfeSDKTypes.generated.h"

UENUM(BlueprintType)
enum class EGfeSDKReturnCode : uint8
{
    Success = 0,
    SuccessIpcOldSdk = 1,
    SuccessIpcOldGfe = 2,
    Error = 3,
    ErrorGfeVersion = 4,
    ErrorSdkVersion = 5,
    ErrorModuleNotLoaded = 6,
	ErrorWrongTimeRangeSet = 7,
	ErrorGeneric = 8,
	ErrorNotImplemented = 9,
	ErrorInvalidParameter = 10,
	ErrorNotSet = 11,
	ErrorShadowplayIRDisabled = 12,
	ErrorSDKInUse = 13,
	ErrorGroupNotFound = 14,
	ErrorFileNotFound = 15,
	ErrorHighlightsSetupFailed = 16,
	ErrorHighlightsNotConfigured = 17,
	ErrorHighlightSaveFailed = 18,
	ErrorUnexpectedException = 19,
	ErrorNoHighlights = 20,
	ErrorNoConnection = 21,
	ErrorPermissionNotGranted = 22,
	ErrorPermissionDenied = 23,
	ErrorInvalidHandle = 24,
	ErrorUnhandledException = 25,
	ErrorOutOfMemory = 26,
	ErrorLoadLibrary = 27,
	ErrorLibraryCallFailed = 28,
	ErrorIPCFailed = 29,
	ErrorConnection = 30,
	ErrorLibCallTimeout = 32,
	ErrorApplicationLookupFailed = 33,
	ErrorApplicationNotKnown = 34,
	ErrorFeatureDisabled = 35,
	ErrorAppNoOptimization = 36,
	ErrorAppSettingsRead = 37,
	ErrorAppSettingsWrite = 38
};

UENUM(BlueprintType)
enum class EGfeSDKScope : uint8
{
    Highlights = 0,
    HighlightsRecordVideo = 1,
    HighlightsRecordScreenshot = 2,
    MAX = 3
};

UENUM(BlueprintType)
enum class EGfeSDKPermission : uint8
{
    Granted = 0,
    Denied = 1,
    MustAsk = 2,
    Unknown = 3,
    MAX= 4
};

UENUM(BlueprintType)
enum class EGfeSDKHighlightType : uint8
{
	NONE		= 0x00,
    Milestone   = 0x01,
    Achievement = 0x02,
    Incident    = 0x04,
    StateChange = 0x08,
	Unannounced = 0x10,
    MAX         = 0x20
};

// This different from the version in sdk_types.h because
// UE4 only supports 8 bit enums. It must be translated
UENUM(BlueprintType)
enum class EGfeSDKHighlightSignificance : uint8
{
	NONE = 0x00,
    ExtremelyBad = 0x01,
    VeryBad = 0x02,
    Bad = 0x04,
    Neutral = 0x08,
    Good = 0x10,
    VeryGood = 0x20,
    ExtremelyGood = 0x40,
    MAX = 0x80
};

USTRUCT(BlueprintType)
struct FGfeSDKCreateInputParams
{
	GENERATED_BODY()

    FGfeSDKCreateInputParams()
    {
        AppName = TEXT("Undefined");
        PollForCallbacks = false;
    }

    UPROPERTY()
    FString AppName;

    UPROPERTY()
    TArray<EGfeSDKScope> RequiredScopes;

    UPROPERTY()
    bool PollForCallbacks;
};

USTRUCT(BlueprintType)
struct FGfeSDKPair
{
	GENERATED_USTRUCT_BODY();

	FGfeSDKPair() {}
	FGfeSDKPair(FString inKey, FString inValue)
	: Key(inKey), Value(inValue)
	{}

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
	FString Key;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
	FString Value;
};

USTRUCT(BlueprintType)
struct FGfeSDKPairScopePermission
{
	GENERATED_USTRUCT_BODY();

	FGfeSDKPairScopePermission() {}
	FGfeSDKPairScopePermission(EGfeSDKScope inKey, EGfeSDKPermission inValue)
	: Key(inKey), Value(inValue)
	{}

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
	EGfeSDKScope Key;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
	EGfeSDKPermission Value;
};

USTRUCT(BlueprintType)
struct FGfeSDKCreateResponse
{
    GENERATED_USTRUCT_BODY()

    FGfeSDKCreateResponse()
    {
        VersionMajor = -1;
        VersionMinor = -1;
        NVIDIAGfeVersion = TEXT("Undefined");
    }

    UPROPERTY()
    uint16 VersionMajor;

    UPROPERTY()
    uint16 VersionMinor;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    FString NVIDIAGfeVersion;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    TArray<FGfeSDKPairScopePermission> ScopePermissions;
};

USTRUCT(BlueprintType)
struct FGfeSDKHighlightDefinition
{
    GENERATED_USTRUCT_BODY()

    FGfeSDKHighlightDefinition()
    {
        UserDefaultInterest = true;
        HighlightTags = static_cast<EGfeSDKHighlightType>(0x0);
        Significance = static_cast<EGfeSDKHighlightSignificance>(0x0);
    }

    FGfeSDKHighlightDefinition(FString const& Id_, bool UserDefaultInterest_, EGfeSDKHighlightType Tags_, EGfeSDKHighlightSignificance Sig_, TMap<FString, FString> Table_) :
        Id(Id_), UserDefaultInterest(UserDefaultInterest_), HighlightTags(Tags_), Significance(Sig_)
	{
		for (auto & Pair : Table_)
		{
			NameTranslationTable.Add(FGfeSDKPair(Pair.Key, Pair.Value));
		}
	}
	// Defines the highlight type name
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    FString Id;
	// If set to true, the highlight will be recorded, otherwise the Shadowplay will lookup the GFE database and user's options. 
	// If it's not found there or user switched of the highlihts for this game, it will be treated as irrelevant.
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    bool UserDefaultInterest;
	// Tag that defines the type of the highlight
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    EGfeSDKHighlightType HighlightTags;
	// This property defines how good or bad the recorded event is in terms of the gameplay
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    EGfeSDKHighlightSignificance Significance;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    TArray<FGfeSDKPair> NameTranslationTable;
};

USTRUCT(BlueprintType)
struct FGfeSDKHighlightConfigParams
{
    GENERATED_USTRUCT_BODY()

    FGfeSDKHighlightConfigParams() {}

	
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    TArray<FGfeSDKHighlightDefinition> HighlightDefinitions;
	
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    FString DefaultLocale;
};

USTRUCT(BlueprintType)
struct FGfeSDKRequestPermissionsParams
{
    GENERATED_USTRUCT_BODY()

    FGfeSDKRequestPermissionsParams() {}

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    TArray<EGfeSDKScope> Scopes;
};

USTRUCT(BlueprintType)
struct FGfeSDKPermissionsChangedData
{
    GENERATED_USTRUCT_BODY()

    FGfeSDKPermissionsChangedData() {}

    UPROPERTY()
	TArray<FGfeSDKPairScopePermission> ScopePermissions;
};

USTRUCT(BlueprintType)
struct FGfeSDKHighlightOpenGroupParams
{
    GENERATED_USTRUCT_BODY()

    FGfeSDKHighlightOpenGroupParams() {}

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    FString GroupId;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    TArray<FGfeSDKPair> GroupDescriptionTranslationTable;
};

USTRUCT(BlueprintType)
struct FGfeSDKHighlightCloseGroupParams
{
    GENERATED_USTRUCT_BODY()

    FGfeSDKHighlightCloseGroupParams(): 
		DestroyHighlights(false) 
	{}

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    FString GroupId;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    bool DestroyHighlights;
};

USTRUCT(BlueprintType)
struct FGfeSDKHighlightScreenshotParams
{
    GENERATED_USTRUCT_BODY()

    FGfeSDKHighlightScreenshotParams() {}

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    FString GroupId;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    FString HighlightId;
};

USTRUCT(BlueprintType)
struct FGfeSDKHighlightVideoParams
{
    GENERATED_USTRUCT_BODY()

    FGfeSDKHighlightVideoParams()
    {
        StartDelta = 0;
        EndDelta = 0;
    }

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    FString GroupId;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    FString HighlightId;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    int32 StartDelta;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    int32 EndDelta;
};

USTRUCT(BlueprintType)
struct FGfeSDKHighlightGroupView
{
    GENERATED_USTRUCT_BODY()

    FGfeSDKHighlightGroupView() :
		TagsFilter(EGfeSDKHighlightType::NONE),
		SignificanceFilter(EGfeSDKHighlightSignificance::NONE)
	{}

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    FString GroupId;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    EGfeSDKHighlightType TagsFilter;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    EGfeSDKHighlightSignificance SignificanceFilter;
};

USTRUCT(BlueprintType)
struct FGfeSDKHighlightSummaryParams
{
    GENERATED_USTRUCT_BODY()

    FGfeSDKHighlightSummaryParams() {}

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shadowplay Highlights")
    TArray<FGfeSDKHighlightGroupView> GroupViews;
};


DECLARE_DELEGATE_OneParam(FGfeSDKOnPermissionsChanged, FGfeSDKPermissionsChangedData const&);
